package io.netty.example.http.websocketx.common.entity;

import io.netty.example.http.websocketx.common.entity.enums.ContentType;
import io.netty.example.http.websocketx.common.entity.enums.DispatchType;
import io.netty.example.http.websocketx.common.entity.enums.MessageScope;

import java.io.Serializable;
import java.util.List;

/**
 * @author fuguangli
 * @description 通信消息
 * @Create date:    2017/4/28
 */
public class NettyMessage implements Serializable {

    private String messageScope = MessageScope.COMMON.toString();
    private String contentType = ContentType.TEXT.toString();
    private String dispatchType = DispatchType.BROADCAST.toString();
    private Object message;

    /*转发对象,在非广播消息的情况下非空*/
    private List<Object> dispatchTarget;
    /*字节数据，当消息为BINARY时非空*/
    private byte[] bytes;

    public byte[] getBytes() {
        return bytes;
    }

    public void setBytes(byte[] bytes) {
        this.bytes = bytes;
    }

    public String getMessageScope() {
        return messageScope;
    }

    public void setMessageScope(String messageScope) {
        this.messageScope = messageScope;
    }

    public String getContentType() {
        return contentType;
    }

    public void setContentType(String contentType) {
        this.contentType = contentType;
    }

    public String getDispatchType() {
        return dispatchType;
    }

    public void setDispatchType(String dispatchType) {
        this.dispatchType = dispatchType;
    }

    public Object getMessage() {
        return message;
    }

    public void setMessage(Object message) {
        this.message = message;
    }

    public List<Object> getDispatchTarget() {
        return dispatchTarget;
    }

    public void setDispatchTarget(List<Object> dispatchTarget) {
        this.dispatchTarget = dispatchTarget;
    }

    @Override
    public String toString() {
        return "NettyMessage{" +
                "messageScope='" + messageScope + '\'' +
                ", contentType='" + contentType + '\'' +
                ", dispatchType='" + dispatchType + '\'' +
                ", message=" + message +
                ", dispatchTarget=" + dispatchTarget +
                '}';
    }
}
